package cn.hhy.org.mapper;

import cn.hhy.org.domain.Department;
import cn.hhy.org.query.DepartmentQuery;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public interface DepartmentMapper {
    /**
     * 新增
     * @param department
     */
    void save(Department department);

    /**
     * 修改
     * @param department
     */
    @Update("update t_department set sn=#{sn}, name=#{name} ,dirPath=#{dirPath},state=#{state},manager_id=#{employee.id},parent_id=#{parent.id} where id=#{id};")
    void update(Department department);

    /**
     * 删除
     * @param id
     */
    @Delete( "delete from t_department where id=#{id}")
    void delete(Long id);

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @Select("select * from t_department where id=#{id}")
    Department loadById(Long id);

    /**
     * 查询全部
     * @return
     */
    @Select("select * from t_department")
    List<Department> loadAll2();

    List<Department> loadAll(DepartmentQuery departmentQuery);

    Long findDepartmentCountByQuery(DepartmentQuery departmentQuery);

    void PatchDelete(Long[] ids);


    @Select("select * from t_department where parent_id=#{id}")
    List<Department> findSonsByPid(Long l);
}
